import { AsMsgQ } from '@/API/api.js'
export default function(){
	const deviceMessage = (devList,devIdRadioValue,callback) => {
		devList.forEach((z, i) => {
			z.channels = [];
			AsMsgQ({
				"body": {
					"caps":'',
					"sn": z.devId
				},
				"method": "reqCaps"
			}).then(res=>{
				const {ret,caps} = res;
				if (ret === 200) {
					let channelKey = 'xmc.css.vid.enable.channels'
					let capsArr = ['xmc.css', 'xmc.voes', 'pms.voes', 'pms.sms', 'net.cellular'];
					z.channels = caps[channelKey] ? caps[channelKey].split('_') : [];//多通道
					z.icon=devIdRadioValue===z.devId ?'unfold': 'fold'
					capsArr.forEach(j=>{
						if(caps[`${j}.support`] || caps[`${j}.vid.support`]){
							z.support = true;
							return;
						}
					})
					if(z.support){
						callback(z)
					}
				}
			}).catch(()=>{})
		})
	}
	return {
		deviceMessage
	}
}